"""
name: Hello Wold
version: 1.0
"""
# from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel

# app = QApplication([])

# widget = QWidget()  
# widget.resize(500, 250)    # 设置主窗口长宽
# widget.setWindowTitle('Hello World')    # 设置主窗口标题文字

# lable = QLabel('按钮示例', widget)  # 创建子控件QLabel标签
# lable.setGeometry(20, 20, 200, 20)  # 设置lable的位置和长宽
# button = QPushButton('点我啊', widget)  # 创建子控件QPushButton
# button.setGeometry(20, 50, 200, 100)  # 设置button的位置和长宽
# button.clicked.connect(widget.close)

# widget.show() 
# app.exec_() 


from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel

class MyWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(500, 250) # 设置窗口长宽
        self.setWindowTitle('Hello World') # 设置窗口标题文字
        self.button = QPushButton('点我啊', self)  
        self.button.setGeometry(20, 50, 200, 100)  
        self.button.clicked.connect(self.close)
        
        self.label = QLabel('按钮示例', self) # 创建子控件QLabel标签
        self.label.setGeometry(20, 20, 200, 20) # 设置lable的位置和长宽

app = QApplication([])  

widget = MyWidget()  
widget.show()  

app.exec_()  
